// stores/userStore.js  
import { defineStore } from 'pinia';  

export const useUserStore = defineStore('user', {  
  state: () => ({  
    userId: null,  
    username: '',  
    // 其他用户信息  
  }),  
  actions: {  
    setUser(user) {  
      console.log('存入用户信息',user);
      
      this.userId = user.userId;  
      this.username = user.username;  
      console.log("设置用户:", user.userId, user.username);  
    },
    clearUser() {  
      this.id = null;  
      this.name = '';  
    },  
  },  
});